<template>
    <div>
        名称：{{insectName}}<br>
        繁殖：{{insectBreed}}<br>
        寄主：{{insectHost}}<br>
        天敌：{{insectEnemy}}<br>
        主要危害：{{insectHarm}}<br>
        防治措施：{{insectPrecaution}}<br>
        幼虫图片：{{smallPhoto}}<br>
        成虫图片：{{bigPhoto}}<br>
        <input type="button" value="返回" @click="close()">
    </div>
</template>

<script>
export default {
    data() {
        return {
            insectId: 2,
            insectName: "",
            insectBreed: "",
            insectHost: "",
            insectEnemy: "",
            insectHarm: "",
            insectPrecaution: "",
            smallPhoto: "",
            bigPhoto: ""
        }
    },
    methods: {
        async getInsectInfo(insectId) {

            console.log(location.search)
			var name1 = location.search.substr(1)
			console.log(name1)
//			进行分割,分割成数组
			var arr = name1.split('?')
			console.log(arr[1])
            var int =name1
			this.insectId = int

        
            let paramObj = { id: this.insectId }
            let cutObj = await this.ajax.getSubmit("/api/insects/selectInsect", paramObj)
            this.insectName = cutObj.insectName;
            this.insectBreed = cutObj.insectBreed;
            this.insectHost = cutObj.insectHost;
            this.insectEnemy = cutObj.insectEnemy;
            this.insectHarm = cutObj.insectHarm;
            this.insectPrecaution = cutObj.insectPrecaution;
            this.insectsmallPhotoName = cutObj.smallPhoto;
            this.bigPhoto = cutObj.bigPhoto;
        },
        close(){
            window.close();
        }
    },

    created() {// 页面被创建时调用的函数 和data，computed，methods同级
        this.getInsectInfo()
    }
}

</script>

<style>

</style>